module.exports = class extends think.Model {
  /**
   * 获取当前用户显示的评论数目
   * @param {*} uid
   */
  async getPublishedCommentsNumberByUid(uid) {
    return await this.where({ status: 'approved', ownerId: uid }).count();
  }

  async getWaitingCommentsNumberByUid(uid) {
    return await this.where({ status: 'waiting', ownerId: uid }).count();
  }

  async getSpamCommentsNumberByUid(uid) {
    return await this.where({ status: 'spam', ownerId: uid }).count();
  }

  /**
   * 获取文章的评论数量
   * @param {*} cid
   */
  async getCommentsNumberByCid(cid) {
    return await this.where({ cid: cid }).count();
  }

  async getPublishedCommentsNumberByCid(cid) {
    return await this.where({ status: 'approved', cid: cid }).count();
  }

  async getWaitingCommentsNumberByCid(cid) {
    return await this.where({ status: 'waiting', cid: cid }).count();
  }

  async getSpamCommentsNumberByCid(cid) {
    return await this.where({ status: 'spam', cid: cid }).count();
  }
};
